package com.baidu.day08;

import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Date;
import java.util.Scanner;

public class Demo02 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输用户的编号:");
        int id = scanner.nextInt();
        System.out.println("请输入用户的名字:");
        String name = scanner.next();
        LocalDate now = LocalDate.now();
        User user = new User(id, name, now);
        System.out.println("用户信息如下:");
        System.out.println(user);

    }

    public static void m1() {
        //创建日期对象
        Date date = new Date();
        System.out.println(date);
        //创建一个日期格式化的模板
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        //按照模板格式化日期
        String formatDate = sdf.format(date);
        System.out.println(formatDate);
    }

    public static void m2() {
        //获取一个时间戳 1730430368838
        //1970年1月1日0时0分0秒  到当前时间  毫秒
        long start = System.currentTimeMillis();
        //打印99乘法表
        for (int i = 1; i <= 9; i++) {
            for (int j = 1; j <= i; j++) {
                System.out.print(j + "*" + i + "=" + i * j + "\t");
            }
            System.out.println();
        }
        long end = System.currentTimeMillis();
        System.out.println(end - start);

    }

    public static void m3() {
        //获取系统当前时间
        LocalDateTime currentTime = LocalDateTime.now();
        System.out.println(currentTime);
        //格式化日期模板
        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
        //格式化日期
        String formatDateTime = currentTime.format(formatter);
        System.out.println(formatDateTime);
    }
}

